package com.xmut.mapper;

import com.xmut.pojo.Voluntary;
import com.xmut.pojo.VoluntaryAct;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VolunteerMapper {
    @Select("select * from t_voluntary where managerid = #{id}")
    List<Voluntary> getVoluntaryById(Integer id);
    @Select("select * from t_voluntary where id = #{id}")
    Voluntary getVoluById(Integer id);

    @Insert("insert into t_voluntary(managerid,title,summary,phone,address,duration,eventtime) values (#{managerid},#{title},#{summary},#{phone},#{address},#{duration},#{eventtime})")
    void insertVoluntary(Voluntary voluntary);

    @Delete("delete from t_voluntary where id = #{id} ")
    void deleteVoluntary(Integer id);

    @Update("update t_voluntary set title = #{title} ,summary = #{summary} ,phone = #{phone} ,address = #{address} ,duration = #{duration} ,eventtime = #{eventtime} where id = #{id} ")
    void updateVoluntary(Voluntary voluntary);

    @Select("select * from t_voluntary")
    List<Voluntary> getAllVoluntary();

    @Insert("replace into t_voluntaryact(userid,username,voluntaryid,voluntarytitle) values (#{userid},#{username},#{voluntaryid},#{voluntarytitle})")
    void insertVolAct(VoluntaryAct voluntaryAct);

    @Select("select * from t_voluntaryact")
    List<VoluntaryAct> getAllVolAct();

    @Delete("delete from t_voluntaryact where id = #{id}")
    void delVolAct(Integer id);
}
